﻿@{
    Layout = null;
}
<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>条码档案信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link href="~/Content/X-admin/css/font.css" rel="stylesheet" />
    <script src="~/Content/X-admin/lib/layui/layui.js"></script>
    <link href="~/Content/X-admin/css/xadmin.css" rel="stylesheet" />
    <script src="~/Content/X-admin/js/jquery.min.js"></script>
    <script src="~/Content/X-admin/js/xadmin.js"></script>
    <script src="~/Content/Scripts/System/systemFrame.js"></script>
    <script src="~/Content/Scripts/System/Common.js"></script>
    <script type="text/html" id="barDemo">

        @*<a title="水洗标列表" href="javascript:;" lay-event="waterWashList" id="subBar"><i class="layui-icon">&#xe66d;</i></a>*@
        @*<a title="水洗标列表" href="javascript:;" lay-event="wwl" id="reBar"><i class="layui-icon">&#xe615;</i></a>*@
        <a title="条码补打" href="javascript:;" lay-event="print" id="reBar"><i class="layui-icon">&#xe66d;</i></a>
        <a title="条码作废" href="javascript:;" lay-event="del" id="dropBar"><i class="layui-icon">&#xe640;</i></a>

    </script>
</head>
<body>
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-body ">
                        <form class="layui-form layui-col-space5" name="qForm" id="qForm">

                            <div class="layui-inline layui-show-xs-block">
                                <input type="text" name="barCode" placeholder="流水号" autocomplete="off" class="layui-input" id="barCode">

                            </div>
                            <div class="layui-inline layui-show-xs-block">
                                <input type="text" name="proCode" placeholder="存货编码" autocomplete="off" class="layui-input" id="proCode">
                            </div>
                            <div class="layui-inline layui-show-xs-block">
                                <input type="text" name="proName" placeholder="存货名称" autocomplete="off" class="layui-input" id="proName">
                            </div>
                            <div class="layui-inline layui-show-xs-block">
                                <select id="wareHouse" name="wareHouse" lay-search class="wareHouse" lay-filter="wareHouse">
                                    <option value="">所属仓库</option>
                                </select>
                            </div>
                            <div class="layui-inline layui-show-xs-block">
                                <select id="barStatus" name="barStatus" class="barStatus">
                                    <option value="">条码状态</option>
                                </select>
                            </div>
                            <div class="layui-inline layui-show-xs-block">
                                <button class="layui-btn" lay-filter="sreach" id="btn-view" type="button" onclick="loadData()"><i class="layui-icon">&#xe615;</i></button>
                            </div>
                        </form>
                    </div>

                    <div class="layui-card-body" id="layui-table-main">
                        <table class="layui-hide" id="list" lay-filter="list"></table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>

</html>

<script>
    var barCodes = "";
    var currPage = 1;//首先默认值为1，防止出错
    function loadData() {
        layui.use('table', function () {
            var conditon = JSON.stringify(FormToJson("qForm"));
            if (conditon.includes("#")) {
                conditon = conditon.replace(/\#/g, "%23");
            }
            var dUrl = "../Bar/GetDataList?dataType=bar&condition=" + conditon;
            var table = layui.table;
            table.render({
                elem: '#list'
                ,height: 'full-200'   //固定高度-即固定表头固定第一行首行
                , cols: [[ //标题栏
                    { type: 'checkbox' }
                    , { field: 'id', title: 'ID', width: 80 }
                    , { field: 'barCode', align: 'center', title: '流水号', width: '7%' }
                    , { field: 'proCode', align: 'center', title: '存货编码', width: '7%', }
                    , { field: 'proName', align: 'center', title: '存货名称', width: '8%' }
                    , { field: 'spec', align: 'center', title: '规格', width: '8%' }
                    , { field: 'chengfen', align: 'center', title: '主要成分', width: '7%' }
                    , { field: 'maoWeight', align: 'center', title: '毛重', width: '6%' }
                    , { field: 'proWeight', align: 'center', title: '重量', width: '6%' }
                    , { field: 'unitName', align: 'center', title: '主计量单位', width: '6%' }
                    , { field: 'deptName', align: 'center', title: '班次', width: '6%' }
                    , { field: 'yaGuang', align: 'center', title: '是否压光', width: '6%' }
                    , { field: 'isInitial', align: 'center', title: '是否期初', width: '6%' }
                    , { field: 'standard', align: 'center', title: '生产标准', width: '8%' }
                    , { field: 'houseName', align: 'center', title: '所属仓库', width: '6%'  }
                    , { field: 'barStatusName', align: 'center', title: '条码状态', width: '6%'  }
                    , { field: 'checkName', align: 'center', title: '检验人员', width: '6%'  }
                    , { field: 'createtime', align: 'center', title: '生产时间', width: '9%'  }
                    , { field: 'right', align: 'center',title: '数据操作', toolbar: '#barDemo', width: 85, fixed: 'right' }
                ]], done: function (res, curr, count) {
                    $("[data-field='id']").css('display', 'none');//隐藏列
                    currPage = curr;
                    //TablePowerHide();
                }
                //   , height: $(document).height() - $('#list').offset().top - 20
                , url: dUrl
                , skin: 'row' //表格风格
                , even: true
                , page: { layout: ['count', 'prev', 'page', 'next', 'skip', 'limit'], groups: 1, first: false, last: false}
                , page: true //是否显示分页
                , limits: [20, 35, 50]
                , limit: 20 //每页默认显示的数量
                , id: "tData"
            });
            //监听工具条
            table.on('tool(list)', function (obj) {
                var data = obj.data;
                if (obj.event == 'print') {
                    SSO("reBar", data.barCode);
                } else if (obj.event == 'del') {
                    layer.confirm('确认要作废选中条码？', function (index) {
                        var info = DelData(data.barCode);
                        if (info.Result) {
                            obj.del();
                        } else {
                            layer.msg(info.Message);
                        }
                        layer.close(index);
                    });
                } else if (obj.event == 'tmzy') {
                    if (data.zy != "1") {
                        layer.msg('此数据无占用信息'); return;
                    }
                    var url = "../Bar/BarZhanYong?barCode=" + data.barCode;
                    NewOpenPage(url, data.barCode + "-条码占用", "90%", "90%", "tData", currPage, dUrl);

                } else if (obj.event == 'wwl') {
                    InfoOpenPage("../Bar/WaterWashCodeList?barCode=" + obj.data.barCode,
                        "条码" + data.barCode + "箱中水洗标列表",
                        "95%", "90%");
                }

            });
            //监听工具条
            table.on('checkbox(list)', function (obj) {
                var data = obj.data;

                //为父窗口input赋值
                barCodes = "";
                var checkStatus = table.checkStatus('list');
                var infos = "";
                for (var i = 0; i < checkStatus.data.length; i++) {
                    infos = infos + checkStatus.data[i].barCode + ",";
                }
                barCodes = infos.substr(0, infos.length - 1);
            });
            // 监听双击事件
            table.on('rowDouble(list)', function (obj) {
                var data = obj.data;

                //layer.alert(JSON.stringify(data), {
                //    title: '当前行数据：'
                //});

                //InfoOpenPage("../Bar/WaterWashCodeList?barCode=" + data.barCode,
                //    "条码" + data.barCode + "箱中水洗标列表",
                //    "95%", "90%");


                ////标注选中样式
                //obj.tr.addClass('layui-table-click').siblings().removeClass('layui-table-click');
            });

        });
    }
   
   
    $(function () {
        //WebPowersShow();
       // wareInfo("wareHouse");
        DictionaryDropDown("bst", "barStatus", "");
        loadData();
        $(document).keyup(function (event) {
            if (event.keyCode == 13) {
                loadData();
            }
        })
    })
    function openWin() {
        InfoOpenPage("../Bar/AddBarCode?planCode=0", "条码添加", "95%", "90%");
    }


    /**
   条码作废
   **/
    function DelData(barCode) {
        var info = undefined;
        $.ajax({
            url: "../Bar/DropBarCode",
            data: { barCode: barCode },
            dataType: "json",
            type: "POST",
            async: false,
            success: function (data) {

                info = data;
            }
        });
        return info;
    }
    /**
    确认选择**/

    function sureChoose() {
        var value = $("#svalue").val();
        if (barCodes == "") {
            layer.msg("没有选择任何数据"); return;
        } else {

            OpenPage("条码重置", "../Bar/ReSetBar?bars=" + barCodes);



        }

    }

    //修改在库条码所在位置（仓库 货位）
    function updateWarePosition(){
        $.ajax({
            url: "../Bar/updateWarePosition",
            dataType: "json",
            type: "POST",
            async: false,
            success: function (data) {
                if (data.Result) {
                    layer.msg("修改成功！");
                }
            }
        });
    }

</script>